home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BBS_UTL / BOI200P / BOIDECL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-13  |  13KB  |  371 lines

  1. { $D-}  { Debug Information Off }
  2. {$S-}  { Stack Checking Off    }
  3. {$V-}  { String Checking Off   }
  4.  
  5. Unit BOIDecl;
  6. { Part of BBS Onliner Interface }
  7. { Copyright (C) 1990,1992 Andrew J. Mead
  8.   All Rights Reserved. }
  9.  
  10. { original version 10/20/90
  11.   history found in IOLIB.PAS }
  12.  
  13. INTERFACE
  14.  
  15. Uses
  16.   crt,
  17.   DOS;
  18.  
  19. Const
  20.   BOI_Version = '1.40';    { BBS Onliner Interface Version Number }
  21.  
  22. { DOS file sharing attributes, used with OpenFile, OpenText }
  23.   read_only  = $00;  { ---- -000 open file for read only }
  24.   writeonly  = $01;  { ---- -001 open file for write only }
  25.   readwrite  = $02;  { ---- -010 open file for reading and writing }
  26.   denyall    = $10;  { -001 ---- deny file access to other programs }
  27.   denywrite  = $20;  { -010 ---- deny write access to other programs }
  28.   denyread   = $30;  { -011 ---- deny read access to other programs }
  29.   denynone   = $40;  { -100 ---- allow full access to other programs }
  30.  
  31. Type
  32.   ptrmask = record   { segment:offset mask for address pointers }
  33.       poff : word;
  34.       pseg : word
  35.     end;
  36.  
  37.   timearr        = array [1..4] of word;       { used in Time/Date functions }
  38.   basearr        = array [$0..$F] of byte;
  39.   facctype       = (treset,trewrite,tappend);  { file access modes }
  40.   tasktype       = (notask,dv,dos5,win,os2);   { CPU taskers }
  41.  
  42.   boi_grmode     = (gr_none,gr_ascii,gr_ansi,gr_avt,gr_tpcrt);
  43.                    { graphics modes : none, ASCII, ANSI, AVATAR, CRT }
  44.   boi_commode    = (com_none,com_local,com_internal,com_fossil);
  45.                    { communication modes : none, local, internal, FOSSIL }
  46.   boi_statmodes  = (sm_help1,sm_time,sm_comm,sm_vid);
  47.                    { status line display options : }
  48.                    {     time left, comm settings, remote video mode }
  49.   boi_dropmode   = (df_none,df_pcb14x,df_other);
  50.                    { drop file types : none, PCBoard 14.x, other }
  51.  
  52.   stdproc        = procedure;  { procedural variable type }
  53.  
  54. Const
  55.   boi_r_color    : boolean = false;      { use color indicator (remote) }
  56.   boi_l_color    : boolean = false;      { use color indicator (local) }
  57.   boi_local      : boolean = true;       { local mode indicator }
  58.   boi_echo       : boolean = false;      { echo info locally indicator }
  59.   boi_quiet      : boolean = false;      { supress local bell ringing }
  60.   boi_ctsrts     : boolean = false;      { modem has locked baud rate }
  61.   boi_replay     : boolean = false;      { allow multiple play }
  62.   boi_checkcd    : boolean = true;       { use carrier detect routines }
  63.   boi_timeover   : boolean = false;      { time has expired indicator }
  64.   boi_againtime  : word    = 10;         { time minimum for Again play }
  65.   boi_statmode   : boi_statmodes = sm_time; { status line display mode }
  66.   boi_allowavt   : boolean = false;      { AVATAR allowed indicator }
  67.   dos_share      : boolean = true;       { DOS SHARE is loaded }
  68.  
  69.   boi_portadd    : word    = $03F8; { Com1 } { serial port address }
  70.   boi_portnum    : word    = 0;     { Com1 } { serial port number (absolute) }
  71.   boi_portint    : word    = $0C;   { IRQ4 } { serial port interrupt vector }
  72.   boi_picmask    : byte    = $EF;   { IRQ4 } { 8259A port initialization value }
  73.   boi_pic2msk    : byte    = $00;   { if IRQ7..IRQ15 used then this is used }
  74.   boi_cascade    : boolean = false; { IRQ7..IRQ15 used indicator }
  75.  
  76.   boi_hoflim     : byte    = 20;   { maximum entries by one player in HOF }
  77.  
  78.   boi_plusidx    : byte    = 0;    { GetCmBBS places ParamStr index value in }
  79.   boi_minusidx   : byte    = 0;    { the given variable.  These are the main }
  80.   boi_equalidx   : byte    = 0;    { program definable variables.  The program }
  81.   boi_closeidx   : byte    = 0;    { must perform any further processing on }
  82.   boi_openidx    : byte    = 0;    { these switches. }
  83.   boi_dotidx     : byte    = 0;
  84.  
  85.   boi_portstatus : boolean = false;      { internal Async not active }
  86.   boi_cmode    : boi_commode = com_none; { remote communications mode }
  87.   boi_cstr     : string    = ' No Comm'; { status line comm mode string }
  88.   foss_init    : byte      = $00;        { FOSSIL initialization option mask }
  89.  
  90.   boi_dmode    : boi_dropmode = df_none; { drop file mode }
  91.   boi_cdlost   : boolean   = false;      { remote dropped carrier indicator }
  92.  
  93.   boi_ticks    : longint   = $17fe80; { timer ticks left (18.2 per second) }
  94.   boi_stall    : longint   = 0;       { timer ticks since last user activity}
  95.   boi_timer    : longint   = 0;       { timer ticks into the game }
  96.   boi_stime    : longint   = 0;       { time stat line was last updated }
  97.   boi_warntime : word      = 5;       { next minute to warn user about time at}
  98.  
  99.   boi_ansiarr  : basearr   = { ANSI colors mapped to text attribute byte }
  100.       (30,34,32,36,31,35,33,37,30,34,32,36,31,35,33,37);
  101.   boi_l_grmode : boi_grmode = gr_tpcrt;  { current local graphics mode }
  102.   boi_r_grmode : boi_grmode = gr_ansi;   { current remote graphics mode }
  103.  
  104.   boi_nextchar : char = #$00; { used to pass character to IOLib.GetString }
  105.  
  106. Type
  107.   str39      = string [39];
  108.   charset    = set of char;
  109.  
  110. Var
  111.   boi_pagelength : byte;        { size of screen in lines }
  112.   boi_username   : str39;       { player's name - if available }
  113.   boi_usename    : boolean;     { availability of users name }
  114.   boi_realname   : str39;       { player's real name (not alias) - if available }
  115.   boi_usereal    : boolean;     { availability of real name }
  116.   boi_gametime   : integer;     { playing time - if available }
  117.   boi_usetime    : boolean;     { use playing time indicator }
  118.   boi_ticksleft  : longint;     { time left to play }
  119.   boi_starttime  : timearr;     { time that game was initialized }
  120.   boi_startdate  : timearr;     { date that game was initialized }
  121.   boi_extraword  : word;        { reserved }
  122.   boi_timexp     : boolean;     { time expired indicator }
  123.   boi_texthof    : pathstr;     { text hall of fame filename }
  124.  
  125.   boi_gamepath   : pathstr;     { full DOS path of game's executable }
  126.   boi_gamedir    : dirstr;      { DOS path of game }
  127.   boi_gamename   : namestr;     { DOS file name (no extension) of game }
  128.   boi_gameext    : extstr;      { DOS file name extension of current game }
  129.  
  130.   boi_tasker : tasktype;        { Operating System/Environment tasker }
  131.   boi_tvers  : word;            { version of boi_tasker }
  132.   boi_tstr   : string;          { string describing boi_tasker }
  133.   boi_tintr  : boolean;         { Interrupt for tasker functions }
  134.   in_dos     : ^boolean;        { DOS active indicator }
  135.  
  136.   BOI_Wait   : stdproc;         { stall procedure / give up time slice }
  137.   BOI_Crit   : stdproc;         { enter critical region }
  138.   BOI_Safe   : stdproc;         { exit critical region }
  139. Procedure BOIInt08h; Interrupt;
  140.  
  141. IMPLEMENTATION
  142. {$F+}
  143. Const
  144.   fossintr = $14;   { FOSSIL interrupt }
  145.   dv_intr  = $15;   { DESQview interrupt }
  146.   dos_intr = $21;   { DOS Services interrupt }
  147.   win_intr = $2F;   { DOS Multiplexor/Windows interrupt }
  148.  
  149.   lastwait : longint = 0; { static variable indicating last time slice }
  150.                           { that was surrendered }
  151.  
  152. Var
  153.   bd_nextexit : pointer;  { pointer to hold address of next Exit procedure }
  154.   oldint08h : pointer;    { pointer to hold previous Timer interrupt }
  155.  
  156. Procedure CALLOLDINT(old : pointer); Far;
  157.   begin {* CallOldInt *}
  158.     Inline($9C/$FF/$5E/$06)
  159.   end;  {* CallOldInt *}
  160.  
  161. Procedure BOIINT08H;
  162.   { chain timer interrupt to handle BOI timing routines }
  163.  
  164.   begin {* iBOIInt08h *}
  165.     if boi_ticks = 0 then boi_timeover := true;
  166.     Dec(boi_ticks);         { decrement time remaining }
  167.     Inc(boi_stall);         { increment inactivity timer }
  168.     Inc(boi_timer);         { increment game timer }
  169.     CallOldInt(oldint08h);  { allow CPU to do its thing first }
  170.     Inline($FB)   { STI }   { allow other interrupts to intercede }
  171.     { additional non-critical processing can go here, in the future
  172.     I plan to write a hook to this section... }
  173.   end;  {* iBOIInt08h *}
  174.  
  175. Procedure NULLPROC; Far;
  176.   begin {* NullProc *}
  177.   end;  {* NullProc *}
  178.  
  179. { DESQview functions }
  180. Procedure DV_WAIT; Far;
  181.   const
  182.     dvregs : registers = (ax : $1000);
  183.  
  184.   begin {* DV_Wait *}
  185.     if boi_timer - lastwait >= 4 then { only give up one in four time slices }
  186.       begin
  187.         Intr(dv_intr,dvregs);
  188.         lastwait := boi_timer
  189.       end
  190.   end;  {* DV_Wait *}
  191.  
  192. Procedure DV_CRIT; Far;
  193.   const
  194.     dvregs : registers = (ax : $DE1C);
  195.  
  196.   begin {* DV_Crit *}
  197.     Intr(dv_intr,dvregs)
  198.   end;  {* DV_Crit *}
  199.  
  200. Procedure DV_SAFE; Far;
  201.   const
  202.     dvregs : registers = (ax : $101C);
  203.  
  204.   begin {* DV_Safe *}
  205.     Intr(dv_intr,dvregs)
  206.   end;  {* DV_Safe *}
  207.  
  208. Function CHECKDV : boolean;   { is DESQview loaded? }
  209.   var
  210.     regs : registers;
  211.  
  212.   begin {* fCheckDV *}
  213.     regs.AX := $2B01;
  214.     regs.CX := $4445;  { DE }
  215.     regs.DX := $5351;  { SQ }
  216.     Intr($21,regs);
  217.     if regs.AL <> $FF then { set initial values }
  218.       begin
  219.         boi_tasker := dv;
  220.         boi_tvers  := regs.BX;
  221.         boi_tintr  := true;
  222.         BOI_Wait := DV_Wait;
  223.         BOI_Crit := DV_Crit;
  224.         BOI_Safe := DV_Safe;
  225.         Str(regs.BH + (regs.BL / 100):0:2,boi_tstr);
  226.         boi_tstr := 'DESQview ' + boi_tstr;
  227.         CheckDV := true
  228.       end
  229.     else CheckDV := false
  230.   end;  {* fCheckDV *}
  231.  
  232.  
  233. { MicroSoft Windows functions }
  234. Procedure MS_WAIT; Far;
  235.   const
  236.     msregs : registers = (ax : $1680);
  237.  
  238.   begin {* MS_Wait *}
  239.     if boi_timer - lastwait >= 4 then { only give up one in four time slices }
  240.       begin
  241.         Intr(win_intr,msregs);
  242.         lastwait := boi_timer
  243.       end
  244.   end;  {* MS_Wait *}
  245.  
  246. Procedure WIN_CRIT; Far;
  247.   const
  248.     winregs : registers = (ax : $1681);
  249.  
  250.   begin {* Win_Crit *}
  251.     Intr(win_intr,winregs)
  252.   end;  {* Win_Crit *}
  253.  
  254. Procedure WIN_SAFE; Far;
  255.   const
  256.     winregs : registers = (ax : $1682);
  257.  
  258.   begin {* Win_Safe *}
  259.     Intr(win_intr,winregs)
  260.   end;  {* Win_Safe *}
  261.  
  262. Function CHECKWINDOZE : boolean; { is MS Windows loaded? }
  263.   var
  264.     regs : registers;
  265.  
  266.   begin {* fCheckWindoze *}
  267.     regs.AX := $1600;
  268.     Intr(win_intr,regs);
  269.     if regs.AL in [$00,$01,$80,$FF] then CheckWindoze := false
  270.     else
  271.       begin { set initial values }
  272.         boi_tasker := win;
  273.         boi_tvers  := regs.AL;
  274.         boi_tintr  := true;
  275.         BOI_Wait := MS_Wait;
  276.         BOI_Crit := Win_Crit;
  277.         BOI_Safe := Win_Safe;
  278.         Str(regs.AL + (regs.AH / 100):0:2,boi_tstr);
  279.         boi_tstr := 'Windows ' + boi_tstr;
  280.         CheckWindoze := true
  281.       end
  282.   end;  {* fCheckWindoze *}
  283.  
  284. Procedure DOS_IDLE; Far;
  285.   begin {* DOS_Idle *}
  286.     Inline($CD/$28)
  287.   end;  {* DOS_Idle *}
  288.  
  289. Procedure CHECKDOSVERS; { set up DOS/DOS box settings }
  290.   var
  291.     regs : registers;
  292.  
  293.   begin {* CheckDOSVers *}
  294.     boi_tintr := false;
  295.     regs.AX := $3001;     { test for DOS version }
  296.     Intr(dos_intr,regs);
  297.     if (regs.AL = $0A) or (regs.AL = $14) then { OS/2 1.x or OS/2 2.x }
  298.       begin  { set OS/2 dos box settings }
  299.         boi_tasker := os2;
  300.         if regs.AL = $0A then
  301.           begin
  302.             boi_tvers := 1;
  303.             boi_tstr := 'OS/2 1.x'
  304.           end
  305.         else
  306.           begin
  307.             boi_tvers := 2;
  308.             boi_tstr := 'OS/2 2.x'
  309.           end;
  310.         BOI_Wait := MS_Wait;  { works fine }
  311.         BOI_Crit := NullProc; {* Unknown *}
  312.         BOI_Safe := NullProc; {* Unknown *}
  313.       end
  314.     else
  315.       begin { set up DOS settings }
  316.         boi_tvers := regs.AX;
  317.         Str(regs.AL + (regs.AH / 100):0:2,boi_tstr);
  318.         boi_tstr := 'DOS ' + boi_tstr;
  319.         BOI_Crit := NullProc;
  320.         BOI_Safe := NullProc;
  321.         if regs.AL = 5 then { is DOS version 5.0? }
  322.           begin
  323.             boi_tasker := dos5;
  324.             BOI_Wait := MS_Wait
  325.           end
  326.         else
  327.           begin
  328.             boi_tasker := notask;
  329.             BOI_Wait := DOS_Idle
  330.           end
  331.       end
  332.   end;  {* fCheckDOSVers *}
  333.  
  334. Procedure SETINDOS; { set up InDos flag }
  335.   type
  336.     ptrmap = array [0..1] of word;
  337.  
  338.   var
  339.     regs  : registers;
  340.     indos : ptrmap absolute in_dos;
  341.  
  342.   begin {* SetInDOS *}
  343.     regs.AH := $34;
  344.     Intr(dos_intr,regs);
  345.     indos[1] := regs.ES;
  346.     indos[0] := regs.BX
  347.   end;  {* SetInDOS *}
  348.  
  349. Procedure BOIEXIT; Far;
  350.   begin {* BOIExit *}
  351.     exitproc := bd_nextexit;
  352.     SetIntVec($08,oldint08h)
  353.   end;  {* BOIExit *}
  354.  
  355. begin {* uBOIDecl *}
  356.   bd_nextexit := exitproc;     { install BOIDecl's exit procedure }
  357.   exitproc := @BOIExit;
  358.   GetIntVec($08,oldint08h);    { save current timer interrupt }
  359.   SetIntVec($08,@BOIInt08h);   { insert BOI timer interrupt }
  360.   GetDate(boi_startdate[1],boi_startdate[2],boi_startdate[3],boi_startdate[4]);
  361.       { set starting date }
  362.   GetTime(boi_starttime[1],boi_starttime[2],boi_starttime[3],boi_starttime[4]);
  363.       { set starting time }
  364.   boi_gamepath := FExpand(ParamStr(0));  { find out who we are! }
  365.   FSplit(boi_gamepath,boi_gamedir,boi_gamename,boi_gameext); { split file }
  366.   SetInDOS;  { get indos flag }
  367.  
  368.   { set up CPU tasker stuff }
  369.   if not CheckDV then if not CheckWindoze then CheckDOSVers
  370. end.  {* uBOIDecl *}
  371.